;;; package --- hydra & which-key

;;; Commentary:

;;; Code:

;; Switch-Modes
;; prefix "C-c m"
(global-set-key (kbd "C-c m a") 'SAS-mode)
(global-set-key (kbd "C-c m e") 'emacs-lisp-mode)
(global-set-key (kbd "C-c m l") 'latex-mode)
(global-set-key (kbd "C-c m m") 'markdown-mode)
(global-set-key (kbd "C-c m o") 'org-mode)
(global-set-key (kbd "C-c m p") 'python-mode)
(global-set-key (kbd "C-c m s") 'shell-script-mode)
(global-set-key (kbd "C-c m x") 'text-mode)
(global-set-key (kbd "C-c m y") 'yaml-mode)

;; remap "C-h"
;; via: Chris
;; (define-key key-translation-map (kbd "C-h") "")
;; (global-set-key (kbd "C-h") 'backward-delete-char-untabify)
;; via: twlz0ne
;; (global-set-key (kbd "C-h") 'delete-backward-char)
;; (global-set-key (kbd "M-h") 'backward-kill-word)
;; (global-set-key (kbd "<f1>") 'help-command)
;; (define-key isearch-mode-map "\C-h" 'isearch-delete-char)

(global-set-key (kbd "C-r") 'replace-string)
(global-set-key (kbd "C-S-r") 'query-replace-regexp)

;; -------- which-key --------
(use-package which-key
  :diminish which-key-mode
  :init
  (setq which-key-idle-delay 0.5
	    which-key-max-description-length 27)
  (which-key-mode)
  (which-key-add-key-based-replacements
    "C-c !" "flycheck"
    ;; site-lisp/windmove
    "C-c h" "window <-"
    "C-c l" "window ->"
    ;; switch modes
    "C-c m" "switch-mode"
    "C-c m a" "SAS"
    "C-c m d" "Rmd"
    "C-c m e" "Σlisp"
    "C-c m l" "LaTeX"
    "C-c m m" "M↓"
    "C-c m o" "Org"
    "C-c m p" "oooooo@"
    "C-c m r" "R"
    "C-c m s" ">_"
    "C-c m x" "teXt"
    "C-c m y" "yaml"
    )
  :config
  (setq which-key-popup-type 'side-window))

;; -------- unbind unneeded keys, via: MatthewZMD
(global-set-key (kbd "C-z") nil)
(global-set-key (kbd "M-z") nil)
(global-set-key (kbd "C-x C-z") nil)

(provide 'keybindings)
